package tr.hba.jblog.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import tr.hba.jblog.dao.IPostDAO;
import tr.hba.jblog.model.Post;

@Service("postService")
public class PostService implements IPostService {

	private IPostDAO entityDAO;

	@Autowired
	public PostService(IPostDAO entityDAO) {
		this.entityDAO = entityDAO;
	}

	@Transactional
	public void create(Post entity) {
		entityDAO.create(entity);

	}

	@Transactional
	public void delete(Post entity) {
		entityDAO.delete(entity);

	}

	@Transactional(readOnly = true)
	public List<Post> findAll() {
		return entityDAO.loadAll();
	}

	@Transactional(readOnly = true)
	public Post findById(Long id) {
		return entityDAO.loadById(id);
	}

	@Transactional
	public void update(Post entity) {
		entityDAO.update(entity);

	}

}
